package com.sky.cqculture.service.impl;

import com.sky.cqculture.Mapper.CommentMapper;
import com.sky.cqculture.pojo.Comment;
import com.sky.cqculture.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {
    
    @Autowired
    private CommentMapper commentMapper;
    
    @Override
    public void addComment(Comment comment) {
        // 设置评论时间
        //comment.setCreateTime(new LocalDateTime());
        // 调用Mapper添加评论
        commentMapper.insert(comment);
    }
    
    @Override
    public List<Comment> findCommentsByHeritageId(Integer heritageId) {
        return commentMapper.findByHeritageId(heritageId);
    }
    
    @Override
    public void deleteComment(Integer id) {
        commentMapper.deleteById(id);
    }
}